//
//  QuestionJSONModel.swift
//  DianShangWen
//
//  Created by 周文轩 on 15/5/7.
//  Copyright (c) 2015年 &#21608;&#25991;&#36713;. All rights reserved.
//

import Foundation
import Argo
import Runes

extension QuestionClassification: Argo.JSONDecodable {
    
    static func create(questioncategoryid: String)(questioncategoryname: String)(questioncount: Int) -> QuestionClassification {
        return QuestionClassification(questioncategoryid: questioncategoryid, questioncategoryname: questioncategoryname, questioncount: questioncount)
    }
    
    static func decode(j: JSONValue) -> QuestionClassification? {
        return QuestionClassification.create
            <^> j <| "questioncategoryid"
            <*> j <| "questioncategoryname"
            <*> j <| "questioncount"
    }
}

extension QuestionsClassification: Argo.JSONDecodable {
    
    static func create(pagecount: Int)(curpage: Int)(totalcount: Int)(questioncategorycount: Int)(questioncategorys: [QuestionClassification]) -> QuestionsClassification {
        return QuestionsClassification(pagecount: pagecount, curpage: curpage, totalcount: totalcount, questioncategorycount: questioncategorycount, questioncategorys: questioncategorys)
    }
    
    static func decode(j: JSONValue) -> QuestionsClassification? {
        return QuestionsClassification.create
            <^> j <| "pagecount"
            <*> j <| "curpage"
            <*> j <| "totalcount"
            <*> j <| "questioncategorycount"
            <*> j <|| "questioncategorys"
    }
}